package dao;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.TreeSet;

public abstract class IPessoaDAO<T> {

    protected ArrayList<Observer> observadores = new ArrayList<Observer>();

    public final void addObserver(Observer observer) {
        observadores.add(observer);
    }

    public final void notifyObservers() {
        for (Observer observer : observadores) {
            observer.update(new TreeSet<T>(this.getPessoas()));
        }
    }

    public abstract boolean add(T p) throws IOException;

    public abstract void addAll(Collection<T> pessoas) throws IOException;

    public abstract boolean altera(T pessoaExistente, String nomeAnterior) throws IOException;

    public abstract void carregaPessoas() throws FileNotFoundException;

    public abstract boolean contains(T p);

    public abstract T getPessoaByName(String nome);

    public abstract Collection<T> getPessoas();

    public abstract boolean remove(String nome) throws IOException;
}
